package com.yjx.client;

import com.yjx.dto.ResourceDto;
import com.yjx.dto.RoleDto;
import com.yjx.entity.Role;
import com.yjx.entity.User;
import com.yjx.util.Result;
import com.yjx.vo.PageVo;
import com.yjx.vo.ParentResourceVo;
import com.yjx.vo.RoleVo;
import com.yjx.vo.UserVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(name = "user-provider")
public interface UserClient {
    @PostMapping("/user/login")
    public UserVo login(@RequestBody User user);

    @PostMapping("/user/getOperateToken")
    public Result getOperateToken();

    @PostMapping("/user/checkRoleCode")
    public Result checkRoleCode(@RequestParam("roleCode") String roleCode);

    @PostMapping("/user/createRole")
    public Result saveRole(@RequestBody Role role,
                            @RequestParam("token") String token,
                           @RequestParam("operateToken") String operateToken);

    @PostMapping("/user/deleteRoleById")
    public Result deleteRoleById(@RequestParam("id")Integer id);

    @PostMapping("/user/checkUserCode")
    public Result checkUserCode(@RequestParam("userCode") String userCode);

    @PostMapping("/user/createUser")
    public Result createUser(@RequestBody User user,
                             @RequestParam("token")String token);
    @PostMapping("/user/queryAllResource")
    public Result<List<ParentResourceVo>> queryAllResource();

    @PostMapping("/user/saveResource")
    public Result saveResource(@RequestBody ResourceDto resourceDto, @RequestParam("token") String token);

    @PostMapping("/user/queryAllRole")
    public Result<List<RoleVo>> queryAllRole();

    @PostMapping("/user/createUserRole")
    public Integer createUserRole(@RequestBody RoleDto roleDto);

    @PostMapping("/user/queryRoleByRoleName")
    public Result<PageVo<RoleVo>> queryRoleByRoleName(
            @RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize,
            @RequestParam(value = "roleName",required = false,defaultValue = "") String roleName);

    @PostMapping("/user/queryUserByUserName")
    public Result<PageVo<UserVo>> queryUserByUserName(
            @RequestParam(value = "pageNum",required = false,defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize,
            @RequestParam(value = "userName",required = false,defaultValue = "") String userName);



}
